package com.steam.hw1;

import java.util.stream.Stream;

/**
 * @author bin
 * @date 2025 - 04 -08
 **/
public class MainTest {
    public static void main(String[] args) {
        Student[] stus = new Student[5];
        stus[0] = new Student("张三", 18);
        stus[1] = new Student("李四", 19);
        stus[2] = new Student("李五", 18);
        stus[3] = new Student("李六", 21);
        stus[4] = new Student("王八", 20);

        Stream<Student> stus1 = Stream.of(stus);

        //只输出前面两个
        stus1.filter(t ->t.getName().startsWith("李"))
                .filter(t->t.getAge()>18)
                .sorted((o1,o2)->o2.getAge()-o1.getAge())
                .map(Student::getName)
                .limit(2)
                .forEach(System.out::println);
    }
}
